home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: ncrgw2.ncr.com!ncrhub2!lznj2!lziss3!netnews
- From: Arnold Bursian <arnold.bursian@germany.ncr.com>
- Subject: Re: Can you overload a constructor?
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <31493335.8C5@germany.ncr.com>
- Sender: netnews@lziss3.lincroftnj.ncr.com (51[news]-Netnews Admin)
- Content-Transfer-Encoding: 7bit
- Organization: AT&T GIS Lincroft, NJ USA
- References: <Do859K.K9B@watserv3.uwaterloo.ca>
- Mime-Version: 1.0
- Date: Fri, 15 Mar 1996 09:07:01 GMT
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
-
- jfournie@sciborg.uwaterloo.ca wrote:
- >
- > Greetings,
- >
- > I am new to C++ and just wanted to make sure it
- > was OK to overload a constructor. gnu c++
- > doesn't have a problem with it, but is it normally
- > done?
- >
- > regards
- >
- > JP Fournier
- > jfournie@sciborg.uwaterloo.ca
-
- Sure, you do it all the time! Just make sure you're calling one of the parent's constructors.
-
- class B
- {
- B( int i, int j );
- ...
- };
-
- B::B( int i, int j )
- {
- ...
- }
-
- class A : public B
- {
- A( int x, int y );
- ...
- };
-
- A::A( int x, int y ) : B( 3, 4 )
- {
- ...
- }
-